package com.chatdating.controller;

import com.chatdating.entity.pojo.Result;
import com.chatdating.service.MatchService;
import com.chatdating.utils.EmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/match")
public class MatchController {
    @Autowired
    private MatchService matchService;

    @PostMapping("/getAll")
    public Result match(Integer userId) {
        if(EmptyUtil.isEmpty(userId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            return Result.success(matchService.getTodayMatches(userId));
        }
    }

    @PostMapping("/closeOne")
    public Result closeOne(Integer userId, Integer closeUserId) {
        if(EmptyUtil.isEmpty(userId) || EmptyUtil.isEmpty(closeUserId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            return Result.success(matchService.closeOneMatches(userId, closeUserId));
        }
    }

    @PostMapping("/likeOne")
    public Result likeOne(Integer userId, Integer likeUserId) {
        if(EmptyUtil.isEmpty(userId) || EmptyUtil.isEmpty(likeUserId)) {
            return Result.error(400,"未获取到用户Id");
        }else{
            return Result.success(matchService.likeOneMatches(userId, likeUserId));
        }
    }

}
